<template>
    <div class="doc-content-wrapper">
        <div class="doc-content-container">
            <div class="doc-content">
                <h2 class="mb-5 flex items-center">数组切割成多维数组</h2>
                <Codemirror :code="code1" name="数组切割成多维数组" class="mb-10" />
            </div>
        </div>
    </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'

export default defineComponent({
    setup () {
        const code1 = ref(`let data1 = [
    {
        "id": 719737,
        "recordId": 30049,
        "lotteryNum": 457461,
        "status": 0,
    },
    {
        "id": 719738,
        "recordId": 30049,
        "lotteryNum": 666780,
        "status": 0,
    },
    {
        "id": 719739,
        "recordId": 30049,
        "lotteryNum": 991096,
        "status": 0,
    },
    {
        "id": 719740,
        "recordId": 30049,
        "lotteryNum": 606799,
        "status": 1,
    },
    {
        "id": 719741,
        "recordId": 30049,
        "lotteryNum": 143179,
        "status": 1,
    }
]

let data2 = [];
for (let i = 0; i < data1.length; i += 3) {
    data2.push(data1.slice(i, i + 3));
}

console.log(JSON.stringify(data2));`)

        return {
            code1
        }
    }
})
</script>

<style scoped>

</style>